<?php
    jimport( 'joomla.application.component.view');
    class NormalViewNormal extends JView
    {
		function display($tpl = null)
		{
			$model = $this->getModel('normal'); //get default model
			
			// list all locations, timespans and industries
			$this->assignRef( 'locations', $model->getLocations() );
			$this->assignRef( 'timespans', $model->getTimespans() );
			$this->assignRef( 'industries', $model->getIndustries() );
			
			// get POST/GET parameters' value
			$locationId = JRequest::getVar('location');
			if($locationId)
			{
				$timespanId = JRequest::getVar('timespan');
				$industryId = JRequest::getVar('industry');
				$enteredKeywords = JRequest::getVar('keywords');
				
				if($locationId > 0)
				{
					$this->assign( 'locationName', $model->getLocationName($locationId));
					// count1 is total of files found using 1st suggested criteria (currentLoc + ALL + ALL)
					$this->assign( 'count1', $model->countFile($locationId, -1, -1, '' ));
				}
				
				if($timespanId > 0) 
				{
					$this->assign( 'timespanName', $model->getTimespanName($timespanId) );
					$this->assign( 'count2', $model->countFile(-1, $timespanId, -1, '' ));
				}
				
				if($industryId > 0) 
				{
					$this->assign( 'industryName', $model->getIndustryName($industryId) );		
					$this->assign( 'count3', $model->countFile(-1, -1, $industryId, '' ));
				}
				
				$results = $model->searchFile($locationId, $timespanId, $industryId, $enteredKeywords );
				$results = $model->getData();
				$this->assign( 'results', $results);
				$this->assign( 'pagination', $model->getPagination());
				$this->assign( 'total', $model->getTotal());
			}
			
			parent::display($tpl); //display defaul template
		}
    }